package poly;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class UserDaoImplTest {
	//1.创建被测试对象
	UserDaoImpl udi = new UserDaoImpl();
	
	// 当每个@Test测试之前都运行一次头上@BeforeEach的方法
	@BeforeEach
	void testInsert() {
		// 循环创建11个用户，进行添加测试
		for (int i = 0 ; i < 11; i++) {
			User u = new User(i); // id = 0 ~10
			System.out.println("添加:" + udi.insert(u));
		}
	}

	@Test
	void testUpdate() {
		User u = new User(3);
		System.out.println("更新:" + udi.update(u));
	}

	@Test
	void testDelete() {
		System.out.println("删除:" + udi.delete(34));
	}

	@Test
	void testSelectById() {
		System.out.println("查询:" + udi.selectById(33));
	}

	@Test
	void testSelectAll() {
		User[] selectAll = udi.selectAll();
		for(User u : selectAll) {
			System.out.println(u);
		}
	}

}
